package io.renren.modules.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.renren.modules.netty.model.ElecmeterMessageObj;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: SocketResponseEncoder
 * @Function: 消息编码
 * @date: May 22, 2017 10:49:11 AM
 *
 * @author Joker
 * @version
 * @since JDK 1.8
 */
@Slf4j
public class SocketEncoder extends MessageToByteEncoder<ElecmeterMessageObj> {
	@Override
	protected void encode(ChannelHandlerContext ctx, ElecmeterMessageObj message, ByteBuf byteBuf) throws Exception {
		byte[] result = null;
//		if (frameType == ElecmeterMessageHeader.FrameType.HEART) {
//			result = RuianZhihuiyongdianProtocol.heartResponse(imei);
//		} else if (frameType == ElecmeterMessageHeader.FrameType.MERGENT) {
//			result = RuianZhihuiyongdianProtocol.mergentResponse(imei);
//		}
		ctx.writeAndFlush(Unpooled.copiedBuffer(result));
	}
}
